package site.jlopen.kuscia.enums;

/**
* @ClassName: JobStateCodeEnum
* @Description: KusciaJob 状态
* @author ChenJiaLu
* @date 2025年3月5日 09:23:50
*
 */
public enum JobStateCodeEnum {
	Unknown(0, "未知"), 
	Pending(1, "未开始运行"), 
	Running(2, "运行中"), 
	Succeeded(3, "成功"), 
	Failed(4, "失败"),
	AwaitingApproval(5, "等待参与方审批 Job"), 
	ApprovalReject(6, "Job 被审批为拒绝执行"), 
	Cancelled(7, "Job 被取消，被取消的 Job 不可被再次执行"),
	Suspended(8, "Job 被暂停，可通过 Restart 接口重跑"), 
	Initialized(9, "Job 初始状态");

	private final Integer number;

	private final String desc;

	JobStateCodeEnum(Integer number, String desc) {
		this.number = number;
		this.desc = desc;
	}

	public Integer getNumber() {
		return number;
	}

	public static String parse(Integer code) {
		for (JobStateCodeEnum value : JobStateCodeEnum.values()) {
			if (value.number.equals(code)) {
				return value.name();
			}
		}
		return null;
	}

	public JobStateCodeEnum value(Integer code) {
		for (JobStateCodeEnum value : JobStateCodeEnum.values()) {
			if (value.number.equals(code)) {
				return value;
			}
		}
		return null;
	}

	public String desc(JobStateCodeEnum value) {
		return value.desc;
	}

	public String desc(Integer code) {
		for (JobStateCodeEnum value : JobStateCodeEnum.values()) {
			if (value.number.equals(code)) {
				return value.desc;
			}
		}
		return null;
	}

}
